﻿ 

	
<!DOCTYPE html>  
<%@page import="com.hh.bss.util.StringHelper" %>
<%
  String companyId=request.getParameter("companyId");  
  
  if (StringHelper.isEmpty(companyId)) companyId="0";
  
%> 
<html>  
<head>  
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">  
    <meta name="keywords" content="公司">  
    <meta name="description" content="公司">  
    <title>公司组织架构</title>  
    
    <%@ include file="/WEB-INF/inc/default.jsp"%>
    <jsp:include page="/WEB-INF/inc/dic.jsp"/>

</head>  
<body>  
    
      
    <ul id="tt" class="easyui-tree" data-options="url:'/customer/company/companyorg.do?companyId=<%=companyId%>',animate:true
    	,onContextMenu: function(e,node){
                e.preventDefault();
                $(this).tree('select',node.target);
                //alert(node.id);
                //console.log(node);
                //console.log(node.attributes.companyNodeType);
                
                if (node.id == 'rootNode') {
                     $('#mm_root').menu('show',{
                       left: e.pageX,
                       top: e.pageY
                     });
                  
                }else if (node.attributes.companyNodeType == 'DEPT') {
                     
                     $('#mm_dept').menu('show',{
                       left: e.pageX,
                       top: e.pageY
                     });
                     
                     //addDept(node);
                  
                }else if (node.attributes.companyNodeType == 'TITLE') {
                     $('#mm_title').menu('show',{
                       left: e.pageX,
                       top: e.pageY
                     });
                }else if (node.attributes.companyNodeType == 'CV') {
                     $('#mm_cv').menu('show',{
                       left: e.pageX,
                       top: e.pageY
                     });
                }
                
                
            }
    	"></ul>  
     
    <div id="mm_root" class="easyui-menu" style="width:120px;">
        <div onclick="addDept()" data-options="iconCls:'icon-add'">新增部门</div>
        <div onclick="editDept()" data-options="iconCls:'icon-edit'">修改部门</div>
        <div onclick="deleteDept()" data-options="iconCls:'icon-remove'">删除部门</div>                
        <div onclick="expand()">展开</div>
        <div onclick="collapse()">收起</div>
    </div> 
    <div id="mm_dept" class="easyui-menu" style="width:120px;">
        <div onclick="test('aa')" data-options="iconCls:'icon-add'">新增部门</div>
        <div onclick="editDept()" data-options="iconCls:'icon-edit'">修改部门</div>
        <div onclick="deleteDept()" data-options="iconCls:'icon-remove'">删除部门</div>        
        <div onclick="addTitle()" data-options="iconCls:'icon-remove'">新增岗位</div>
        <div onclick="expand()">展开</div>
        <div onclick="collapse()">收起</div>
    </div>
    <div id="mm_title" class="easyui-menu" style="width:120px;">
        <div onclick="addTitle()" data-options="iconCls:'icon-add'">新增岗位</div>
        <div onclick="editTitle()" data-options="iconCls:'icon-edit'">修改岗位</div>
        <div onclick="deleteTitle()" data-options="iconCls:'icon-remove'">删除岗位</div>        
        <div onclick="expand()">展开</div>
        <div onclick="collapse()">收起</div>
    </div> 
    <div id="mm_cv" class="easyui-menu" style="width:120px;">       
        <div onclick="deleteCv()" data-options="iconCls:'icon-remove'">删除人员</div>        
        <div onclick="expand()">展开</div>
        <div onclick="collapse()">收起</div>
    </div> 
    
     <div id="dlg-dept" class="easyui-dialog" style="width:600px;height:280px;padding:10px 20px"  
            closed="true" buttons="#dlg-buttons">  
        <form id="fm-dept" method="post" novalidate>  
        	  	  	 <input type="hidden" name="id" > 
        	  	  	 <input type="hidden" name="companyId" >
        	  	  	 
	        		     <div class="fitem">  
                     <label style="width:100px">名称<font color="red">*</font>:</label>                                            
                     <input name="name" class="easyui-box easyui-validatebox"  required="true">                       
                   </div> 
	        		     <div class="fitem">  
                     <label style="width:100px">备注:                      
                     <textarea name="comment" style="height:60px;width:150px">
                   </div> 	        		             		     	        		     
        </form>  
    </div> 
    
    <div id="dlg-title" class="easyui-dialog" style="width:600px;height:280px;padding:10px 20px"  
            closed="true" buttons="#dlg-buttons">  
        <form id="fm-title" method="post" novalidate>  
        	  	  	 <input type="hidden" name="id" > 
        	  	  	 <input type="hidden" name="companyId" >
        	  	  	 <input type="hidden" name="deptId" >
        	  	  	 <input type="hidden" name="parentId" >
	        		     <div class="fitem">  
                     <label style="width:100px">名称<font color="red">*</font>:</label>                                            
                     <input name="name" class="easyui-box easyui-validatebox"  required="true">                       
                   </div> 
	        		     <div class="fitem">  
                     <label style="width:100px">备注:                      
                     <textarea name="comment" style="height:60px;width:150px">
                   </div> 	        		             		     	        		     
        </form>  
    </div>
    <div id="dlg-buttons">  
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" onclick="save('fm-dept','dlg-dept')">Save</a>  
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')">Cancel</a>  
    </div>
    <script type="text/javascript">
    	 function test(){
    	 	 alert('aa');
    	 }	
    	 /*
    	 function addDept(node){
    	 	  url='/customer/companyDept/save.do';
    	 	  $('#dlg-dept').dialog('open').dialog('setTitle','新增部门');    	 	  
    	 	  $('#fm-dept input[name="companyId"]').attr("value",node.attributes.companyId);
    	 }
    	 function editDept(node){
    	 	  url='/customer/companyDept/update.do';
    	 	  $('#dlg-dept').dialog('open').dialog('setTitle','修改部门');
    	 	  $('#fm-dept').form('load','/customer/companyDept/get.do?id='+node.attributes.deptId); 
    	 }
    	 function deleteDept(id){    	                   
                   $.messager.confirm('重要提示','确定要删除?',function(r){  
                       if (r){  
                           $.post('/customer/companyDept/delete.do',{ids:id},function(result){  
                               if (result.success){                                     
                               } else {                                      
                                   $.messager.alert('错误',result.errorMsg,'error'); 
                               }  
                           },'json');  
                       }  
                   });  
               
    	 }
    	 function addTitle(){
    	 	  url='/customer/companyTitle/save.do';
    	 	  $('#dlg-dept').dialog('open').dialog('setTitle','新增岗位');    	 	  
    	 	  $('#fm-dept input[name="companyId"]').attr("value",node.attributes.companyId);
    	 	  $('#fm-dept input[name="deptId"]').attr("value",node.attributes.deptId);
    	 }
    	 function editTitle(){
    	 	  url='/customer/companyTitle/update.do';
    	 	  $('#dlg-dept').dialog('open').dialog('setTitle','修改岗位');
    	 	  $('#fm-dept').form('load','/customer/companyTitle/get.do?id='+node.attributes.titleId); 
    	 }
    	 function deleteTitle(){
    	 }
    	 function deleteCv(){
    	 }
        function save(formid,dlgid){          	   
        	  if (!$('#'+formid).form('validate')) return; 
            $('#'+formid).form('submit',{  
                url: url,  
                onSubmit: function(){  
                    return $(this).form('validate');  
                },  
                success: function(result){  
                    var result = eval('('+result+')');  
                    console.log(result);
                    if (result.success == true){  
                        $.messager.alert('信息',result.msg,'info');  
                        if (dlgid) $('#'+dlgid).dialog('close');      // close the dialog  
                        //if (dgid) $('#'+dgid).datagrid('reload');    // reload the user data  
                    } else {  
                        $.messager.alert('错误',result.msg,'error');
                    }  
                }  
            });  
        }    	 
        */
    </script>	
</body>  
</html>